<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@include file="common/head.jsp" %>
<div class="right_col" role="main">
    <div id="dy" style="height: 600px;width: 1100px;margin-top: 50px;margin-left:20px;">
        <div id="mainChart" style="border: 1px solid #438FB9; width:100%; height:45%;"></div>
    </div>
    <div class="clearfix"></div>
</div>
<%@include file="common/footer.jsp" %>
<script type="text/javascript">
    //使用ajax加载数据 
    $.ajax({
        method: 'POST',
        url: '${pageContext.request.contextPath}/admin/flatform/sales/monthlyEChartsData',
        success: function (data) {
            console.log(data)
            initChat(data);
        }
    });

    function initChat(data) {
        var res = JSON.parse(data);
        var myChart = echarts.init(document.getElementById('mainChart'));
        myChart.setOption(
            {
                title: {
                    text: '',
                    subtext: '',
                    x: 'center'
                },
                tooltip: {
                    trigger: 'axis'
                },
                legend: {
                    data: res.comName
                },
                toolbox: {
                    show: true,
                    feature: {
                        dataZoom: {
                            yAxisIndex: 'none'
                        },
                        magicType: { type: ['line', 'bar'] },
                        restore: {},
                        saveAsImage: {}
                    }
                },
                xAxis: {
                    type: 'category',
                    boundaryGap: false,
                    data: res.timeKey
                },
                yAxis: {
                    type: 'value'
                },
                series: res.commodity
            }
        )
    };
</script>
<script src="${pageContext.request.contextPath }/statics/js/jquery.min.js"></script>
<script src="${pageContext.request.contextPath }/statics/js/echarts.min.js"></script>